package com.yuntuzhilian.chapter3;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author MrWang-shuizhishuiheshui
 * @description 字节流的形式处理写出的信息
 */
public class TestFileOutputStream {
    public static void main(String[] args) {
        //声明fos对象
        FileOutputStream fos=null;

        try {
            fos=new FileOutputStream("test1.txt");
            String str="我哩个去~~~";
            //将字符串转化为字节数组
            byte[] words = str.getBytes();
            //将字节数组内容写出
            fos.write(words,0,words.length);
            System.out.println("写出成功");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //释放资源
            if (fos!=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
